Skip to content

add mapcache mutation helpers - #21

Merged
Peyton-Spencer merged 1 commit into
mainfrom
agent/mapcache-mutations
Jul 7, 2026
Merged

add mapcache mutation helpers#21
Peyton-Spencer merged 1 commit into
mainfrom
agent/mapcache-mutations

Conversation

@Peyton-Spencer

@Peyton-Spencer Peyton-Spencer commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add MapCache.Delete for removing a single cached key
  • add MapCache.Clear for emptying the cache
  • cover direct mutation behavior for Set, Delete, and Clear

Validation

  • go test ./mapcache

Summary by CodeRabbit

  • New Features

    • Added options to remove a single cached entry or clear all cached entries at once.
    • Cache updates now support deleting values directly without recreating the cache.
  • Tests

    • Expanded coverage for setting, deleting, and clearing cache entries.
    • Verified cache reads, refresh behavior, and full-cache iteration after clearing.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0ed60e53-8c59-45d6-87f0-24baf01f7e06

📥 Commits

Reviewing files that changed from the base of the PR and between 8484b36 and acac5f7.

📒 Files selected for processing (2)
  • mapcache/mapcache.go
  • mapcache/mapcache_test.go

📝 Walkthrough

Walkthrough

This PR adds two new methods, Delete and Clear, to MapCache, each acquiring the write lock before mutating the underlying map. Corresponding tests validate Set overwrite behavior, Delete removal with updater re-invocation, and Clear emptying the cache.

Changes

MapCache Mutation Methods

Layer / File(s) Summary
Delete and Clear implementation
mapcache/mapcache.go
Adds locked Delete(key) and Clear() methods that remove a single entry or all entries from the cache map.
Test coverage for Set, Delete, Clear
mapcache/mapcache_test.go
Adds tests verifying Set overwrite updates value and timestamp, Delete removes a key and triggers updater re-invocation on subsequent Get, and Clear empties At/All.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit hopped into the cache one day,
"Delete this, Clear that," it liked to say.
With locks held tight and maps swept clean,
Tests confirmed just what was seen.
Hop, hop, hooray for tidy code today! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change by describing the new MapCache mutation helpers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/mapcache-mutations

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Peyton-Spencer
Peyton-Spencer merged commit 1e60c7c into main Jul 7, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant